<script setup>
import { ref } from 'vue'
import { onLaunch, onShow, onLoad } from '@dcloudio/uni-app'
//引入API

//引入子组件

//引入props

//引入store
import { useMemberStore } from '@/store'
const memberStore = useMemberStore()
//请求数据初始化页面
const handleAddressClick = () => {
  uni.navigateTo({
    url: '/pages/address/list/index',
  })
}

const handleLogout = async () => {
  try {
    await memberStore.logout()
  } catch (error) {
    console.error('退出失败:', error)
    uni.showToast({
      title: '退出失败，请重试',
      icon: 'none',
    })
  }
}
</script>

<template>
  <view class="settings-container">
    <view class="setting-item" @tap="handleAddressClick">
      <text>我的收货地址</text>
      <uni-icons type="arrowright" size="20" color="#999"></uni-icons>
    </view>
    <view class="setting-item logout" @tap="handleLogout">
      <text>退出登录</text>
    </view>
  </view>
</template>

<style lang="scss">
.settings-container {
  padding: 20rpx;
  background-color: #fff;

  .setting-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20rpx;
    border-bottom: 1rpx solid #eee;
    font-size: 32rpx;
    color: #333;

    &.logout {
      color: #ff4444;
      justify-content: center;
    }
  }
}
</style>
